package org.budo.poi;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;

import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author lmw
 */
@Getter
@NoArgsConstructor
public class AbstractRow implements Row {
    private Integer rownum;

    private Map<Short, Cell> cells = new LinkedHashMap<Short, Cell>();

    public AbstractRow(int rownum) {
        this.rownum = rownum;
    }

    @Override
    public String toString() {
        return super.toString() + ", rownum=" + rownum + ", cells=" + cells;
    }

    @Override
    public Cell getCell(int cellnum) {
        return cells.get((short) cellnum);
    }

    @Override
    public short getFirstCellNum() {
        Entry<Short, Cell> first = cells.entrySet().iterator().next();
        return first.getKey();
    }

    @Override
    public short getLastCellNum() {
        Entry<Short, Cell> last = null;
        for (Entry<Short, Cell> each : this.cells.entrySet()) {
            last = each;
        }

        return last.getKey();
    }

    @Override
    public Iterator<Cell> iterator() {
        throw new RuntimeException();
    }

    @Override
    public Cell createCell(int column, int type) {
        throw new RuntimeException();
    }

    @Override
    public void removeCell(Cell cell) {
        throw new RuntimeException();
    }

    @Override
    public void setRowNum(int rowNum) {
        throw new RuntimeException();
    }

    @Override
    public int getRowNum() {
        throw new RuntimeException();
    }

    @Override
    public Cell getCell(int cellnum, MissingCellPolicy policy) {
        throw new RuntimeException();
    }

    @Override
    public int getPhysicalNumberOfCells() {
        throw new RuntimeException();
    }

    @Override
    public void setHeight(short height) {
        throw new RuntimeException();
    }

    @Override
    public void setZeroHeight(boolean zHeight) {
        throw new RuntimeException();
    }

    @Override
    public boolean getZeroHeight() {
        throw new RuntimeException();
    }

    @Override
    public void setHeightInPoints(float height) {
        throw new RuntimeException();
    }

    @Override
    public short getHeight() {
        throw new RuntimeException();
    }

    @Override
    public float getHeightInPoints() {
        throw new RuntimeException();
    }

    @Override
    public boolean isFormatted() {
        throw new RuntimeException();
    }

    @Override
    public CellStyle getRowStyle() {
        throw new RuntimeException();
    }

    @Override
    public void setRowStyle(CellStyle style) {
        throw new RuntimeException();
    }

    @Override
    public Iterator<Cell> cellIterator() {
        throw new RuntimeException();
    }

    @Override
    public Sheet getSheet() {
        throw new RuntimeException();
    }

    @Override
    public Cell createCell(int column) {
        throw new RuntimeException();
    }
}